<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>登录页</title>
<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    $(function(){
        $("#submit").click(function(){
            var loginName1 = $("input[name='loginName']").val();    //获取账号
            var password1 = $("input[name='password']").val();        //获取密码
 
            var jsonUser = {loginName:loginName1, password:password1};    //JSON对象
           
            //注意:jsonUser.toString()这种方法错误,javaScript中的toString是用于布尔型变量的,而应用以下方法
            var strUser = JSON.stringify(jsonUser);    //将JSON对象转变成JSON格式的字符串,
           
            //$.post("jLogin.action", {json: strUser}, callback, "json");
            $.ajax({
            	   type : "POST",
            	   url  : "jLogin.action",
            	   //dataType:"json",
            	   //data : "myJson=" + categoryJson,
            	   data:{json:strUser},
            	   dataType:"json",
            	   success : function(data, textStatus, jqXHR) {
            		   //console.log(jqXHR);
            		   console.log(data);
            	   },
            	   error : function(XMLHttpRequest, textStatus, errorThrown) {
            	    alert("保存失败！3");
            	   }
        	});
 
        /*function callback(json){
            alert(json.msg);    //显示反馈信息
            if(json.suc == 1){    //如果返回"登录成功"
                window.location.href = "admin/index.action";    //跳转到后台主页
            }
        }*/
       
    });
    });
</script>
</head>
<body>
 
<form action="jLogin.action" method="post">
    账号<input type="text" name="loginName"/><br/>
    密码<input type="password" name="password"><br/>
    <input type="button" id="submit" value="登录"/>
</form>
 
</body>
</html>